package com.action;

import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.dao.UserDAO;
import com.myuser.User;

public class LoginAction extends Action{
	public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws SQLException {  
        User user = (User)form;  
        UserDAO dao=new UserDAO();
        ResultSet rs= dao.login(user.getUserName());
        if (rs.next()) { 
        	rs.close();
            return mapping.findForward("success");  
        } else {  
        	rs.close();
        	return mapping.findForward("relogin"); 
        } 
    }  
}
